window.vm = new Vue({
    el: '#app',
    data: {

        approve1: '',
        approve2: '',
        approve3: '',
        //评分
        rate: null,
        oneNo:'',
        onePro:'',
        text:['非常不满意','不满意','一般','满意','非常满意'],
        rateRemark: '',


        // activeName: 'second',
        // accepted: 0
    },
    methods: {
        changeValue:function (value){
            vm.rate = value
            // vm.onePro.score = value
        },

        oneBack:function (){
            top.location.href = "userProcess.html"
        },
        geticon(value) {
            let icon = ''
            if (value==1) {
                icon = 'el-icon-check'
            }else if(value==2){
                icon = 'el-icon-close'
            }
            return icon
        },


        submitOnePro:function (){
            vm.onePro.score = vm.rate
            vm.onePro.rateRemark = vm.rateRemark
            if(vm.onePro.fileList)
                vm.onePro.fileList = vm.onePro.fileList.join(', ')
            if(vm.rate===''||vm.rate==null)
                alert('还没进行评分')
            else {
                axios({
                    method: 'post',
                    url: '/updateProcess',
                    headers:{
                        'Context-Type': 'application/json' // 1
                    },
                    data: this.onePro// 2
                }).then((res) => {
                    alert("服务单评价成功")
                    top.location.href = "userProcess.html"
                });
            }

        },

    },

    created: function () {

        let params = new URLSearchParams(window.location.search);
        let processNo
        if(params.get("processNo"))
            processNo = JSON.parse(params.get("processNo"))
        else
            processNo = JSON.parse(sessionStorage.getItem("processNo"))

        axios.get(
            "/getPro",{
                params: {
                    processNo: processNo
                }
            }
        ).then(function (res) {
            vm.onePro = res.data
            if(vm.onePro.fileList)
                vm.onePro.fileList = vm.onePro.fileList.split(", ")
        }).catch(e => {
            ajaxError(vm, e);
        });

        axios.get(
            "/approve1",{
                params: {
                    processNo: processNo
                }
            }
        ).then(function (res) {
            vm.approve1 = res.data
        }).catch(e => {
            ajaxError(vm, e);
        });

        //获取第二个审批
        axios.get(
            "/approve2",{
                params: {
                    processNo: processNo
                }
            }
        ).then(function (res) {
            vm.approve2 = res.data
        }).catch(e => {
            ajaxError(vm, e);
        });

        //获取第三个审批
        axios.get(
            "/approve3",{
                params: {
                    processNo: processNo
                }
            }
        ).then(function (res) {
            vm.approve3 = res.data
        }).catch(e => {
            ajaxError(vm, e);
        });

    },
});


